/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.ivanbiz.dao.impl;

import com.ivanbiz.dao.PenghuniDAO;
import com.ivanbiz.model.Kamar;
import com.ivanbiz.model.Penghuni;
import com.ivanbiz.service.HibernateUtil;
import org.hibernate.Session;

/**
 *
 * @author City_Z
 */
public class PenghuniDAOImpl extends GenericDAOImpl implements PenghuniDAO {

    @Override
    public String saveAndUpdate(Penghuni penghuni, Kamar kamar) throws Exception {
        String status = "";
        try {
            HibernateUtil.beginTransaction();
            Session session = HibernateUtil.getSession();
            session.saveOrUpdate(penghuni);
            session.saveOrUpdate(kamar);
            HibernateUtil.commitTransaction();
            status = "sukses";
        } catch (Exception e) {
            status = "error";
            HibernateUtil.rollbackTransaction();
        } finally {
            HibernateUtil.closeSession();
        }
        return status;
    }

}
